home *** CD-ROM | disk | FTP | other *** search
/ Risc World 5 / Risc World 5.iso / SOFTWARE / Issue3 / Games / xrick / !xrick / src / c / e_bullet < prev    next >
Text File  |  2004-06-24  |  2KB  |  81 lines

  1. /*
  2.  * xrick/src/e_bullet.c
  3.  *
  4.  * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
  5.  *
  6.  * The use and distribution terms for this software are contained in the file
  7.  * named README, which can be found in the root of this distribution. By
  8.  * using this software in any fashion, you are agreeing to be bound by the
  9.  * terms of this license.
  10.  *
  11.  * You must not remove this notice, or any other, from this software.
  12.  */
  13.  
  14. #include "system.h"
  15. #include "game.h"
  16. #include "ents.h"
  17. #include "e_bullet.h"
  18.  
  19. #include "maps.h"
  20.  
  21. /*
  22.  * public vars (for performance reasons)
  23.  */
  24. S8 e_bullet_offsx;
  25. S16 e_bullet_xc, e_bullet_yc;
  26.  
  27. /*
  28.  * Initialize bullet
  29.  */
  30. void
  31. e_bullet_init(U16 x, U16 y)
  32. {
  33.   E_BULLET_ENT.n = 0x02;
  34.   E_BULLET_ENT.x = x;
  35.   E_BULLET_ENT.y = y + 0x0006;
  36.   if (game_dir == LEFT) {
  37.     e_bullet_offsx = -0x08;
  38.     E_BULLET_ENT.sprite = 0x21;
  39.   }
  40.   else {
  41.     e_bullet_offsx = 0x08;
  42.     E_BULLET_ENT.sprite = 0x20;
  43.   }
  44. #ifdef ENABLE_SOUND
  45.   syssnd_play(WAV_BULLET, 1);
  46. #endif
  47. }
  48.  
  49.  
  50. /*
  51.  * Entity action
  52.  *
  53.  * ASM 1883, 0F97
  54.  */
  55. void
  56. e_bullet_action(UNUSED(U8 e))
  57. {
  58.   /* move bullet */
  59.   E_BULLET_ENT.x += e_bullet_offsx;
  60.  
  61.   if (E_BULLET_ENT.x <= -0x10 || E_BULLET_ENT.x > 0xe8) {
  62.     /* out: deactivate */
  63.     E_BULLET_ENT.n = 0;
  64.   }
  65.   else {
  66.     /* update bullet center coordinates */
  67.     e_bullet_xc = E_BULLET_ENT.x + 0x0c;
  68.     e_bullet_yc = E_BULLET_ENT.y + 0x05;
  69.     if (map_eflg[map_map[e_bullet_yc >> 3][e_bullet_xc >> 3]] &
  70.     MAP_EFLG_SOLID) {
  71.       /* hit something: deactivate */
  72.       E_BULLET_ENT.n = 0;
  73.     }
  74.   }
  75. }
  76.  
  77.  
  78. /* eof */
  79.  
  80.  
  81.